import { ActionContext } from 'vuex'
import { AppState } from './state'
import { IStore } from '@/store/types'
import { setCookie } from '@/utils/auth'

export const actions = {
  toggleSideBar({ commit }: ActionContext<AppState, IStore>) {
    commit('TOGGLE_SIDEBAR')
  },
  closeSideBar({ commit }: ActionContext<AppState, IStore>, withoutAnimation: boolean) {
    commit('CLOSE_SIDEBAR', withoutAnimation)
  },
  toggleDevice({ commit }: ActionContext<AppState, IStore>, device: string) {
    commit('TOGGLE_DEVICE', device)
  },
  setSize({ commit }: ActionContext<AppState, IStore>, size: string) {
    commit('SET_SIZE', size)
  },
  setLanguage({ commit }: ActionContext<AppState, IStore>, language: string) {
    setCookie('language', language)
    commit('SET_LANGUAGE', language)
  }
}
